/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.gwsistemas.buonny.util;

import java.io.StringReader;

/**
 *
 * @author Olimpio
 */
public class Conversor {
    public static Object unmarshal(Object objetoInstanciado, String xml) {
        Object obj = null;
        try {
            if (xml != null) {
                System.out.println(objetoInstanciado.getClass().getPackage().getName());
                javax.xml.bind.JAXBContext jaxbCtx = javax.xml.bind.JAXBContext.newInstance(objetoInstanciado.getClass().getPackage().getName());
                javax.xml.bind.Unmarshaller unmarshaller = jaxbCtx.createUnmarshaller();
                obj = unmarshaller.unmarshal(new StringReader(xml));
            }
        } catch (javax.xml.bind.JAXBException ex) {
            ex.printStackTrace();
        }
        return obj;

    }
}
